<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <!-- key保证如果改变前后的两个元素的key是相同的，就会直接复用，提高性能 -->
        <!-- key必须保证不重复, key必须是数字或者字符串 -->

        <!-- 尽量不要使用index作为key -->
        <li v-for="(item, index) in list" :key="item.id">{{ item.message }}</li>
      </ul>
      <button @click="fn">btn</button>
    </div>

    <script src="../../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          list: [
            { message: "Foo", id: 1 },
            { message: "Bar", id: 2 },
          ],
          arr: [1, 2, 3, 3, 3],
        },
        methods: {
          fn() {
            this.list.push({
              message: "Zoo",
              id: 3,
            });
          },
        },
      });
    </script>
  </body>
</html>
